home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / Include / syncTypes.h < prev    next >
C/C++ Source or Header  |  1990-10-08  |  5KB  |  156 lines

  1. /*
  2.  * syncTypes.h --
  3.  *
  4.  *     Definitions of types for the synchronization module.
  5.  *     The synchronization module provides locks and condition
  6.  *     variables to other modules, plus a low level binary semaphore 
  7.  *    needed to synchronize with interrupt handlers.
  8.  *
  9.  *    The behavior of the sync module can be modified using compiler 
  10.  *    variables. These variables will change the structure of locks and
  11.  *    how the locks are used. In general it is not a good idea to link
  12.  *    modules that have been compiled with different versions of locks.
  13.  *    
  14.  *        <default> -     semaphores and locks have fields that contain a
  15.  *              character string name, the pc where the lock was
  16.  *             last locked, and a pointer to the pcb of the last
  17.  *             lock holder. The locking operation is slower because
  18.  *             these fields must be updated.
  19.  *
  20.  *        CLEAN_LOCK - locks do not contain any extra fields. This version
  21.  *                 of locks is intended for benchmarking the kernel.
  22.  *    
  23.  *        LOCKREG    - locks are registered so that the information stored
  24.  *             in them can be retrieved. In addition to the fields
  25.  *             in the default version of locks, a count of hits
  26.  *             and misses on each lock is kept. Lock registration
  27.  *             must be done when the lock is created and destroyed.
  28.  *             The locking operation is slower due to the hit/miss
  29.  *             counters.  A count is kept for each spin lock that
  30.  *             records the number of times a processor spun waiting
  31.  *             for the lock.
  32.  *
  33.  *        LOCKDEP    - Each lock keeps a list of locks that were held when
  34.  *             it was locked in addition to the information kept
  35.  *             in the LOCKREG version. Locks compiled with LOCKDEP
  36.  *                 will get very large. This information can be used to 
  37.  *             construct a graph of the locking behavior of the
  38.  *             kernel. Locking and unlocking is slowed down due
  39.  *             to the necessity of recording previously held lock.
  40.  *
  41.  *
  42.  * Copyright 1986 Regents of the University of California
  43.  * All rights reserved.
  44.  *
  45.  * $Header: /sprite/src/kernel/sync/RCS/syncTypes.h,v 1.3 90/10/08 12:14:12 jhh Exp $ SPRITE (Berkeley)
  46.  */
  47.  
  48. #ifndef _SYNCTYPES
  49. #define _SYNCTYPES
  50.  
  51. #ifdef KERNEL
  52. #include <user/sync.h>
  53. #include <procTypes.h>
  54. #include <syncLock.h>
  55. #include <machTypes.h>
  56. #include <user/proc.h>
  57. #else
  58. #include <sync.h>
  59. #include <kernel/procTypes.h>
  60. #include <kernel/syncLock.h>
  61. #include <kernel/machTypes.h>
  62. #include <proc.h>
  63. #endif /* */
  64.  
  65. /*
  66.  * If CLEAN_LOCK is defined then don't register locks and don't keep track
  67.  * of lock dependency pairs.
  68.  */
  69. #ifdef CLEAN_LOCK
  70. #undef LOCKREG
  71. #undef LOCKDEP
  72. #endif
  73.  
  74. /*
  75.  * If LOCKDEP is  defined then we need to register locks.
  76.  */
  77. #ifdef LOCKDEP
  78. #define LOCKREG
  79. #endif
  80.  
  81. /*
  82.  * Flags for syncFlags field in the proc table:
  83.  *
  84.  *  SYNC_WAIT_REMOTE            - The process is on a wait list somewhere on
  85.  *                                some host and will block until it gets a
  86.  *                                wakeup message.
  87.  *  SYNC_WAIT_COMPLETE          - The process was doing a remote wait and
  88.  *                                it has received a wakeup message.
  89.  */
  90.  
  91. #define    SYNC_WAIT_COMPLETE    0x1
  92. #define    SYNC_WAIT_REMOTE    0x2
  93.  
  94. /*
  95.  * Definitions of variables for instrumentation.
  96.  */
  97.  
  98. typedef struct Sync_Instrument {
  99.     int numWakeups;        /* number of wakeups performed */
  100.     int numWakeupCalls;        /* number of calls to wakeup */
  101.     int numSpuriousWakeups;    /* number of incorrectly awakened sleeps */
  102.     int numLocks;        /* number of calls to MASTER_LOCK */
  103.     int numUnlocks;        /* number of calls to MASTER_UNLOCK */
  104.     int spinCount[SYNC_MAX_LOCK_TYPES+1]; /* spin count per lock type */
  105.     int sched_MutexMiss;    /* number of times we missed sched_Mutex
  106.                  * in the idle loop. */
  107. #if VMMACH_CACHE_LINE_SIZE != 0
  108.     char pad[VMMACH_CACHE_LINE_SIZE];
  109. #endif
  110. } Sync_Instrument;
  111.  
  112. /*
  113.  * Structure used to keep track of lock statistics and registration. 
  114.  * One of these exists for each type of lock, and the active locks of the type
  115.  * is linked to the activeLocks field. 
  116.  */
  117. typedef struct Sync_RegElement {
  118.     List_Links         links;            /* used to link into lists */
  119.     int            hit;            /* number of hits on type */
  120.     int            miss;            /* number of misses on type */
  121.     int            type;            /* type of lock */
  122.     char        *name;            /* name of type */
  123.     Sync_LockClass    class;            /* either semaphore or lock */
  124.     int            priorCount;        /* count of prior types */
  125.     int            priorTypes[SYNC_MAX_PRIOR]; /* prior types */
  126.     int            activeLockCount;    /* # active locks of type */
  127.     List_Links        activeLocks;        /* list of active locks */
  128.     int            deadLockCount;        /* # deactivated locks */
  129. } Sync_RegElement;
  130.  
  131. /*
  132.  * Structure for System V semaphores.
  133.  */
  134. typedef struct semid_ds Sync_SysVSem;
  135.  
  136.  
  137. /*
  138.  * Define a structure to keep track of waiting processes on remote machines.
  139.  */
  140.  
  141. typedef struct {
  142.     List_Links    links;        /* Link info about related waiting processes */
  143.     int        hostID;        /* Host ID of waiting process */
  144.     Proc_PID    pid;        /* ID of waiting process */
  145.     int        waitToken;    /* Local time stamp used to catch races */
  146. } Sync_RemoteWaiter;
  147.  
  148. /*
  149.  * Wait token value used to wakeup a process regardless of its value of
  150.  * the wait token.
  151.  */
  152. #define    SYNC_BROADCAST_TOKEN    -1
  153.  
  154. #endif /* _SYNCTYPES */
  155.  
  156.